<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <p>count的值是：{{count}}</p>
        <button @click="addCount(1,$event)">+N</button>
    </div>
    <script src="./lib/vue-2.6.12.js"></script>
    <script>
        const mv = new Vue({
            el: '#app',
            data: {
                count: 0
            },
            methods: {
                addCount(n, e) {
                    this.count = this.count + n;
                    // 判断奇偶数
                    if (this.count % 2 == 0) {
                        e.target.style.backgroundColor = 'red';
                    } else {
                        e.target.style.backgroundColor = 'blue';
                    }
                }
            }
        })
    </script>
</body>

</html>